<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html">
    <meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>会员登录</title>
    <link href="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/media.css">
</head>

<body>
    <div class="m-header hidden-lg hidden-md hidden-sm">
        <div class="nav-left">
            <div class="btn-burger navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </div>
        </div>
        <div class="wrapper___2_acE"></div>
        <!-- <div class="user-dropmenu-mask"></div> -->
        <div class="user-dropmenu" style="height:0px;opacity: 1;top: 50px;">
            <div class="search">
                <div class="input-group">
                    <span class="input-group-addon glyphicon glyphicon-search" id="basic-addon1"></span>
                    <input type="text" class="form-control" placeholder="搜索" aria-describedby="basic-addon1">
                </div>
            </div>
            <ul class="ant-menu">
                <li>
                    <div class="ant-menu-submenu-title">工作台</div>
                    <ul class="ant-menu-inline">
                        <li class="ant-menu-item"><a href="index.html" class="active">首页</a></li>
                        <li class="ant-menu-item"><a href="platform.html" class="">平台商</a></li>
                        <li class="ant-menu-item"><a href="industry.html" class="">行业雷达</a></li>
                        <li class="ant-menu-item"><a href="market.html" class="">市场雷达</a></li>
                        <li class="ant-menu-item"><a href="index.html" class="">行业活动</a></li>
                        <li class="ant-menu-item"><a href="index.html" class="">雷达广场</a></li>
                    </ul>
                </li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">帮助</a></li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">发现</a></li>
            </ul>
            <ul class="ant-menu">
                <li class="ant-menu-item"><a href="#" style="background: #fff;">个人页面</a></li>
                <li class="ant-menu-item"><a href="#" style="background: #fff;">退出</a></li>
            </ul>
        </div>
    </div>
    <!-- user -->
    <div class="userBox clearfix">
        <div class="login-box clearfix">
            <div class="logo"><a href="/"><img src="img/logo.png" width="180"></a></div>
            <div class="formBox clearfix">
                <div class="hd">
                    <ul>
                        <li class="active">登录</li>
                        <li><a href="reg.html">注册</a></li>
                    </ul>
                </div>
                <div class="bd">
                    <ul class="clearfix">
                        <form id="myform" action="" method="post">
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-user" aria-hidden="true"></i></div>
                                <input type="text" name="username" class="form-control" id="" placeholder="邮箱">
                            </div>
                            <div class="input-group">
                                <div class="input-group-addon"><i class="glyphicon glyphicon-lock" aria-hidden="true"></i></div>
                                <input type="password" name="password" class="form-control" id="" placeholder="登录密码">
                            </div>
                            <div class="checkbox">
                                <label>
                                    <input type="checkbox" name="data[auto]" value="1" checked="checked" id="checkbox-id"> 记住密码
                                </label>
                                <a class="forgot-password pull-right" href="{dr_member_url('login/find')}">忘记密码？</a>
                            </div>
                            <div class="btnsend">
                                <input type="button" id="login-btn" class="btn-diycolor btn-block" value="立即登录">
                            </div>
                        </form>
                    </ul>
                </div>
            </div>
        </div>
        <div class="login-bg hidden-xs"></div>
    </div>
    <div class="h5-footer hidden-lg hidden-md hidden-sm">
        <div class="main">
            <li><a href="#"><i class="glyphicon glyphicon-home"></i><span>首页</span></a></li>
            <li><a href="#"><i class="glyphicon glyphicon-star"></i><span>产品中心</span></a></li>
            <li><a href="#"><i class="glyphicon glyphicon-star"></i><span>产品中心</span></a></li>
            <li><a href="#"><i class="glyphicon glyphicon-user"></i><span>我的</span></a></li>
        </div>
    </div>
</body>
<script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"> </script>
<script src="https://cdn.bootcss.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdn.bootcss.com/js-cookie/2.2.1/js.cookie.min.js"></script>
<script src="js/md5.js"></script>
<script src="js/core.js"></script>
<script src="js/mine.js"></script>
<script>
$(function() {
    // console.log(localStorage)
    // 用户登录
    if (localStorage.token != null) {
        let getUserName = JSON.parse(localStorage.username);
        let getPassword = JSON.parse(localStorage.password);
        console.log(getUserName)
        $("input[name='username']").val(getUserName);
        $("input[name='password']").val(getPassword);
        $("#login-btn").click(function() {
            $("#login-btn").click(function() {
                username = $("input[name='username']").val();
                password = $("input[name='password']").val();
                md5password = hex_md5(password);
                Getdata(login, { username, password:md5password}, `POST`)
                    .then(res => {
                        console.log(res)
                        if (res.code == "FAIL") {
                            alert(res.msg)
                            return;
                        }
                        if (res.code == "SUCCESS") {
                            localStorage.setItem("token", JSON.stringify(res.data.token));
                            // 存储用户信息
                            localStorage.setItem("user", JSON.stringify(res.data));
                            if ($('#checkbox-id').is(':checked')) {
                                localStorage.setItem("username", JSON.stringify(username));
                                localStorage.setItem("password", JSON.stringify(password));
                                // localStorage.setItem("name", JSON.stringify(res.));
                            } else {
                                localStorage.setItem("username", "");
                                localStorage.setItem("password", "");
                            }
                            //登录成功跳转首页
                            window.location.href = "index.html";
                        }
                    })

            })
        })
    } else {
        let username = "";
        let password = "";
        $("#login-btn").click(function() {
            username = $("input[name='username']").val();
            password = $("input[name='password']").val();
            md5password = hex_md5(password);
            console.log(md5password)
            Getdata(login, { username, password: md5password }, `POST`)
                .then(res => {
                    console.log(res)
                    if (res.code == "FAIL") {
                        alert(res.msg)
                        return;
                    }
                    if (res.code == "SUCCESS") {
                        localStorage.setItem("token", JSON.stringify(res.data.token));
                        // 存储用户信息
                        localStorage.setItem("user", JSON.stringify(res.data));
                        if ($('#checkbox-id').is(':checked')) {
                            localStorage.setItem("username", JSON.stringify(username));
                            localStorage.setItem("password", JSON.stringify(password));
                            // localStorage.setItem("name", JSON.stringify(res.));
                        } else {
                            localStorage.setItem("username", "");
                            localStorage.setItem("password", "");
                        }
                        //登录成功跳转首页
                        window.location.href = "index.html";
                    }
                })

        })
    }
























})
</script>

</html>